package cn.user.domain.dao;

import java.util.List;
import org.springframework.jdbc.core.BeanPropertyRowMapper;
import org.springframework.jdbc.core.JdbcTemplate;
import cn.user.domain.Food;

public class FoodDao {
	private JdbcTemplate jdbctemplate = new JdbcTemplate(Druid0.getDataSource());
	
	public List<Food> findAll(int cityid){
		String sql = "select * from foodlist where cityid = ? ";
		return jdbctemplate.query(sql,new BeanPropertyRowMapper<Food>(Food.class),cityid);
	}
	
	public void add(Food food) {
		String sql = "INSERT INTO foodlist VALUES(?,?,?,?,?,?,?,?)";
		jdbctemplate.update(sql, food.getFoodid(),food.getFoodname(),food.getFoodinf(),food.getFimg1(),food.getFimg2()
				,food.getFimg3(),food.getFimg4(),food.getCityid());
	}
	
}
